package com.yxc.emqxdemo.controller;

import com.yxc.emqxdemo.configuration.EmqxClient;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;

/**
 * @author: 杨旭晨
 * @time: 2022/9/15 15:33
 **/
@Slf4j
@RestController
@RequestMapping("/demo")
public class DemoController {

    @Autowired
    private EmqxClient emqxClient;

    @GetMapping("sendMessage")
    public String sendMessage(@RequestParam String message) {
        emqxClient.publish("emqx-demo", message);
        return "发送成功";
    }

}
